package com.gsit.expenditure.domain;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.gsit.expenditure.utils.InvoiceStatus;

@Entity
@Table(name = "invoice")
@NamedQueries({ @NamedQuery(name = "Invoice.findAll", query = "select invoice from Invoice invoice") })
public class Invoice extends BaseEntity implements Serializable {

	private static final long serialVersionUID = 1L;

	@Column(name = "invoiceNumber")
	private String invoiceNumber;

	@Column(name = "status")
	@Enumerated(EnumType.STRING)
	private InvoiceStatus status;

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	private Set<Bill> bills;
	
	@OneToOne(optional = true , cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	@JoinColumn(name = "invoiceStorage_id", insertable=true)
	private InvoiceStorage invoiceStorage ;
	
	public String getInvoiceNumber() {
		return invoiceNumber;
	}

	public void setInvoiceNumber(String invoiceNumber) {
		this.invoiceNumber = invoiceNumber;
	}

	public InvoiceStatus getStatus() {
		return status;
	}

	public void setStatus(InvoiceStatus status) {
		this.status = status;
	}

	
	public Set<Bill> getBills() {
		return bills;
	}

	public void setBills(Set<Bill> bills) {
		this.bills = bills;
	}
	
	public InvoiceStorage getInvoiceStorage() {
		return invoiceStorage;
	}

	public void setInvoiceStorage(InvoiceStorage invoiceStorage) {
		this.invoiceStorage = invoiceStorage;
	}

	@Override
	public String toString() {
		return "Invoice [invoiceNumber=" + invoiceNumber + ", status=" + status
				+ ", bills=" +  ", invoiceStorage=" + invoiceStorage
				+ ", getId()=" + getId() + ", getCreatedDate()="
				+ getCreatedDate() + ", getModifiedDate()=" + getModifiedDate()
				+ ", getVersion()=" + getVersion() + ", getClass()="
				+ getClass() + ", hashCode()=" + hashCode() + ", toString()="
				+ super.toString() + "]";
	}



}
